/*导航条样式选定的控制*/
var navBarStyle = function(){
    /*WebSite.renderNavBar("NavContainer");*/

    $("#subnav li a").each(function(){
        $this = $(this);
        if($this[0].href==String(window.location)){
            $this.parent("li").addClass("am-active");
        }
    });

    /*$("#index").attr("href",WebSite.IndexPage.url);
     $("#myProblem").attr("href",WebSite.MyQuestionListPage.url);
     $("#allQuestion").attr("href",WebSite.AllQuestionPage.url);
     $("#essenceQuestion").attr("href",WebSite.EssenceQuestionPage.url);*/
};


/*搜索按钮添加并传递数据*/
var searchClick = function(){
    <!--搜素结果数据-->
    $("#searchButton").click(function(){
        var kw = encodeURI($("#kw").val());
        var params = $.param({
            "keyword":kw
        });
        /*window.location.href = "search.html?"+params;*/
        window.location.href = WebSite.SearchResultPage.url + "&" + params;
    });
};


/*通过截取用户名来随机生成图片*/
Handlebars.registerHelper("imgUrl", function(pk_sool_user, options){
    var number;
    if(pk_sool_user == null){
        number = 1;
    }else{
        number = pk_sool_user.substring(pk_sool_user.length-1);
    }
    return "static/avatar/avatar00"+number+".jpg";
});

/*相似问题的字数的控制显示*/
Handlebars.registerHelper("similaryQuestion_length",function(similary_length,options){
    var similaryQuestion_title;
    if(similary_length.length > 10){
        similaryQuestion_title = similary_length.substring(0,10)+"...";
    }else{
        similaryQuestion_title = similary_length;
    }
    return similaryQuestion_title;
});

